<?php 
# 文件名称:fdform.view.php
# MetInfo在线反馈系统 
# Copyright (C) 长沙米拓信息技术有限公司 (http://www.metinfo.cn). All rights reserved.
class fdformView extends C_view
{
	function fdformView()
	{
		parent::C_view();
	}
	//加载模板
	function display($tpl)
	{		
		$SYS = &get_instance();
		$this->assignRef('message', $SYS->loader->getMessageQueue());
		$SYS->html->script('core.js');
		C_html::_('behavior.calendar');
		switch($tpl)
		{			
			case 'add':
			case 'edit':	
							if( $tpl=='add' )
							{
								$this->assignRef( 'title', C_text::_('fdform add'));
								$this->assignRef( 'subTitle',C_text::_('AddForm'));
								$SYS->request->setVar( 'cid', array(0));
								$this->assign('apply', "add");
							}else
							{
								$this->assignRef( 'title', C_text::_('fdform edit'));
								$this->assignRef( 'subTitle',C_text::_('EditForm'));
								$this->assign('apply', "edit");
							}							
							$this->assignRef('item', $this->get('Item'));
							$this->assignRef('namefield', $this->get('Name'));
							$this->assignRef('replycontent', $this->get('ReplyContent'));
							$this->assignRef('introducefield', $this->get('Introduce'));
							$this->assignRef('replysubject', $this->get('ReplySubject'));
							$this->assignRef('replaymailto', $this->get('EmailField'));
							$themes = C_html::_('select.genericlist',   $this->get('Themes'), 'theme', ' class="inputbox"  onchange="changeTheme();"', 'value', 'text', $this->item['theme'] );
							$this->assignRef( 'themes', $themes);
							$this->getJS();
							parent::display('fdform_edit');break;
			default:
							$this->assignRef( 'title', C_text::_('fdform manager'));
							$this->assignRef( 'items', $this->get('Items'));
							$this->assignRef( 'lists', $this->get('Lists'));
							$this->assignRef( 'pagination', $this->get('Pagination'));
							$js_content="markRows();";
							$SYS->doc->addScriptDeclaration($js_content);
							parent::display('fdform');
		}
	}
	////加载js库
	function getJS()
	{
		$SYS = &get_instance();
		$SYS->html->script('mootools-more.js');
		$SYS->html->script('ckeditor.js','plugins/editors/ckeditor/');
		$js_content="
			CKEDITOR.config.toolbar = 'MetinfoToolbar';
			CKEDITOR.config.toolbar_MetinfoToolbar =
			[
			    ['Source','Preview'],
				['Cut','Copy','Paste','PasteText','PasteFromWord'],
				['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
				['Bold','Italic','Underline','Strike'],
				'/',
				['Subscript','Superscript'],
				['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
				['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
				['Link','Unlink','Anchor'],
				['Image','Flash','Table','HorizontalRule','Smiley'],
				'/',
				['Styles','Format','Font','FontSize'],
				['TextColor','BGColor']
			];			
			CKEDITOR.config.width = '600px';
			var meteditor;
			function replaceContent( name )
			{
				if ( meteditor )
					meteditor.destroy();
			
				meteditor = CKEDITOR.replace( name, {
							toolbar : 'MetinfoToolbar',
							filebrowserUploadUrl : '".WEBSELF."/fdform/upload'
					}
				);
			}
			function checkPaging()
			{
				if(meteditor==undefined) return true;
				return Paging.submit();
			}
			window.addEvent('domready', function() {
			$$('.hasTip').each(function(el) {
				var title = el.get('title');
				var parts = title.split('::', 2);
				el.store('tip:title', parts[0]);
				el.store('tip:text', parts[1]);
			});
			var JTooltips = new Tips($$('.hasTip'), { maxTitleChars: 50, fixed: false});
			new Accordion($$('.pane-toggler'), 
				$$('.pane-slider'), 
				{
					onActive: function(toggler, i) 
					{ 
						toggler.addClass('pane-toggler-down');toggler.removeClass('pane-toggler'); 
					},
					onBackground: function(toggler, i) 
					{ 
						toggler.addClass('pane-toggler'); toggler.removeClass('pane-toggler-down'); 
					},
					duration: 300,opacity: false,alwaysHide: true
				});
		});
			var LEFT_CAL = Calendar.setup({
            weekNumbers: true,
            selectionType: Calendar.SEL_MULTIPLE,					
            showTime: 12
            // titleFormat: '%B %Y'
		 })
          new Calendar({
                  inputField: 'startdate',
                  //dateFormat: '%Y-%m-%d %H:%M:%S',
				  dateFormat: '%Y-%m-%d',
				  minuteStep: 1,
                  trigger: 'f_rangeStart_trigger',
                  bottomBar: false,
                  onSelect: function() {
                          var date = Calendar.intToDate(this.selection.get());
                          LEFT_CAL.args.min = date;
                          LEFT_CAL.redraw();
                          this.hide();
                  }
          });
		  new Calendar({
                  inputField: 'finishdate',
                  //dateFormat: '%Y-%m-%d %H:%M:%S',
				  dateFormat: '%Y-%m-%d',
				  minuteStep: 1,
                  trigger: 'f_rangeEnd_trigger',
                  bottomBar: false,
                  onSelect: function() {
                          var date = Calendar.intToDate(this.selection.get());
                          LEFT_CAL.args.min = date;
                          LEFT_CAL.redraw();
                          this.hide();
                  }
         });
		
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}
			var flag = false;
			$$('.must').each(function(el) {
				if(el.get('value')!='')
					flag=true;
			});
			// do field validation
			if (form.access.value == 0) {
				alert( '".C_text::sprintf('Item23',C_text::_('Item6'))."' );
			} else if (!flag) {
				alert('".C_text::_('Must')."');
			} else {
				submitform( pressbutton );
			}
		}
		function changeTheme()
		{
			var form = document.adminForm;
		}
		";
		$SYS->doc->addScriptDeclaration($js_content);
	}
}
# 本程序是一个开源系统,使用时请你仔细阅读使用协议,商业用途请自觉购买商业授权.
# Copyright (C) 长沙米拓信息技术有限公司 (http://www.metinfo.cn). All rights reserved.
?>